package com.fub.positioning;

import java.util.Collection;
import java.util.HashMap;
import java.util.Map;

public class ReferencePointMap {

	private Map<String, ReferencePoint> referencePointsMappedByLocation;

	/**
	 * Constructs a new map for reference points.
	 */
	public ReferencePointMap() {
		this.referencePointsMappedByLocation = new HashMap<String, ReferencePoint>();
	}

	/**
	 * Returns a reference point by location.
	 * 
	 * @param location
	 *            the location of the reference point
	 * @return a reference point by location
	 */
	public ReferencePoint getReferencePoint(String location) {
		return this.referencePointsMappedByLocation.get(location);
	}

	/**
	 * Returns all reference points.
	 * 
	 * @return all reference points
	 */
	public Collection<ReferencePoint> getReferentsPoints() {
		return this.referencePointsMappedByLocation.values();
	}

	/**
	 * Adds a new reference point to map.
	 * 
	 * @param referencePoint
	 *            the new reference point
	 */
	public void addReferencePoint(ReferencePoint referencePoint) {
		this.referencePointsMappedByLocation.put(referencePoint.getLocation(),
				referencePoint);
	}

	/**
	 * Deletes a reference point by location.
	 * 
	 * @param location
	 *            the location of the reference point
	 */
	public void deleteReferencePoint(String location) {
		this.referencePointsMappedByLocation.remove(location);
	}

	/**
	 * Deletes all reference points.
	 */
	public void deleteReferencePoints() {
		this.referencePointsMappedByLocation.clear();
	}
}
